/*
* Copyrigth 2008 Company All rigths reserved
* File Name: ILaboratory.cs
* Created By:    Wenbin.Xu
* Created Date:   2013/7/8 16:27:26
* Description:    Laboratory模块的接口
* Change History: 
* 
* */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrainingsApp.Model;
using TrainingsApp.DAL;
using System.Web.UI.WebControls;

namespace TrainingsApp.Logic {
    public class TS_Preview_Result_Logic {

        public static void TS_Preview_Result_UpdateGroupId(List<TS_Preview_Result_Entity> list) {
            TS_Preview_Result_DAL.TS_Preview_Result_UpdateGroupId(list);
        }

        public static void TS_Preview_Result_UpdateSort(TS_Preview_Result_Entity entity) {
            TS_Preview_Result_DAL.TS_Preview_Result_UpdateSort(entity);
        }

        public static void TS_Preview_Result_GroupUp(TS_Preview_Result_Entity entity) {

            TS_Preview_Result_DAL.TS_Preview_Result_GroupUp(entity);
        }

        public static int TS_Preview_Result_MaxGroupId(Guid previewId) {
            return TS_Preview_Result_DAL.TS_Preview_Result_MaxGroupId(previewId) + 1;
        }

        public static List<TS_Preview_Result_Collecion> TS_Preview_Result_ListByPreviewId(Guid previewId) {
            var allList = TS_Preview_Result_DAL.TS_Preview_Result_ListByPreviewId(previewId);

            return allList.GroupBy(u => u.GroupId.Value).Select(u => new TS_Preview_Result_Collecion {
                TotalCount = u.Count(),
                TS_Preview_Result_List = u.ToList(),
                GroupId = u.Key
            }).ToList();
        }

        public static List<TS_Preview_Result_Collecion> TS_Preview_Result_ListByPreviewId(Guid previewId, long classId) {
            var allList = TS_Preview_Result_DAL.TS_Preview_Result_ListByPreviewId(previewId, classId);

            return allList.GroupBy(u => u.GroupId.Value).Select(u => new TS_Preview_Result_Collecion {
                TotalCount = u.Count(),
                TS_Preview_Result_List = u.ToList(),
                GroupId = u.Key
            }).ToList();
        }


        public static TS_Preview_Result_Collecion TS_Preview_Result_ListByPaging(int pageSize, int pageIndex) {
            return TS_Preview_Result_DAL.TS_Preview_Result_ListByPaging(pageSize, pageIndex);
        }

        public static TS_Preview_Result_Entity TS_Preview_Result_View(System.Guid PreviewId, System.Int64 UsreId) {
            return TS_Preview_Result_DAL.TS_Preview_Result_View(PreviewId, UsreId);
        }

        public static TS_Preview_Result_Entity TS_Preview_Result_Add(TS_Preview_Result_Entity entity) {
            return TS_Preview_Result_DAL.TS_Preview_Result_Add(entity);
        }

        public static void TS_Preview_Result_Update(TS_Preview_Result_Entity entity) {
            TS_Preview_Result_DAL.TS_Preview_Result_Update(entity);
        }

        public static void TS_Preview_Result_Delete(System.Guid PreviewId, System.Int64 UsreId) {
            TS_Preview_Result_DAL.TS_Preview_Result_Delete(PreviewId, UsreId);
        }

        public static List<TS_Preview_Result_Entity> TS_Preview_Result_GetTypicalByPreviewId(Guid PreviewId) {
            return TS_Preview_Result_DAL.TS_Preview_Result_GetTypicalByPreviewId(PreviewId);
        }

        public static List<TS_Preview_Result_Entity> TS_Preview_Result_GetTypicalByPreviewIdAndClassId(Guid previewId, long classId) {
            return TS_Preview_Result_DAL.TS_Preview_Result_GetTypicalByPreviewIdAndClassId(previewId, classId);
        }

        public static List<TS_Preview_Result_Entity> TS_Preview_Result_GetTypicalByPreviewId2(Guid PreviewId, out long resultCount) {
            return TS_Preview_Result_DAL.TS_Preview_Result_GetTypicalByPreviewId2(PreviewId, out resultCount);
        }

        public static int TS_Preview_Result_GetCountByPreviewId(Guid PreviewId) {
            return TS_Preview_Result_DAL.TS_Preview_Result_GetCountByPreviewId(PreviewId);
        }

    }
}
